package cn.edu.pku.ss.situationperceiver;

import cn.edu.pku.ss.situationperceiver.ContextData.ContextType;

public class ContextShareManager {
	/**
	 * Module: Context Sharing Manager (Serve as the core of the Context sharing
	 * mechanism) Responsibilities: 1) Express interest -> When local sensor
	 * can't satisfy the context request, it will transfer the request to this
	 * module. Therefore this module should take the context request and send it
	 * to all the peers. 2) Respond to interest -> Check whether the needed
	 * context is existed. If true then check the privacy level and send it back
	 * to the requester peer. Otherwise it will check it has the sensory
	 * capability to generate this kind of context, or ignore this request.
	 * (Above two methods are done by sending instructions to AllJoynService) 3)
	 * Check local sensory capability with specific context type -> by interact
	 * with the Sensor Manager.
	 */
	public static void queryContext(ContextType contextType) {
		/*
		 * For ContextInterpreter (SRA drives) query context. First check if
		 * there is a valid context (ContextMessage not expired ). If there is
		 * not, query SensorManager for local sensors, If local sensors can't
		 * offer this type of context, then build a ContextSharingRequest and
		 * broadcast to all the peers over the opportunistic network as a way of
		 * EXPRESSING INTEREST.
		 */
		ContextMessage context = null;
		/**
		 * Phase 1. Check existing valid context.
		 */
		/**
		 * Phase 2. Query SensorManager.
		 */
		/**
		 * Phase 3. Build a ContextSharingRequest and send it to all peers on the session. use another method in this class.
		 */
		
		/**
		 * I Phase: Save to database.
		 */

	}

	public static void receiveContextMessage(ContextMessage contextMsg) {
		/*
		 * After AllJoynService module receive a ContextMessage (check recipient
		 * of course), its handler will deliver the content of the message
		 * (ContextMessage here) to this method.
		 */
	}

	private static ContextSharingRequest buildSharingRequest(
			ContextType contextType) {
		/*
		 * For local method queryContext() use, to build a context sharing
		 * request for it.
		 */
		return null;
	}
}
